package club.twelveblog.tblog.common.advice;

import club.twelveblog.tblog.common.exception.BlogException;
import club.twelveblog.tblog.common.vo.ExceptionResult;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 *
 */
@ControllerAdvice
public class CommonExceptionHandler {

    @ExceptionHandler(BlogException.class)
    public ResponseEntity<ExceptionResult> handlerException(BlogException e){
        return ResponseEntity.status(e.getExceptionEnum().getCode()).body(new ExceptionResult(e.getExceptionEnum()));
    }
}
